//
//  UIButton+UIButton.m
//  SinaBlog_OC
//
//  Created by macs on 15/11/16.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

#import "UIButton+UIButton.h"

@implementation UIButton (UIButton)
//convenience init(title : String? , color : UIColor?, icon: String?,image : String = "",size : CGFloat = 14){
//    self.init()
//    
//    setTitle(title, forState:  .Normal)
//    setTitleColor(color, forState: .Normal)
//    
//    if icon != nil {
//        setBackgroundImage(UIImage(named:icon ?? ""), forState: .Normal)
//        setBackgroundImage(UIImage(named:icon ?? "" + "_highlighted"), forState: .Highlighted)
//    }
//    
//    setImage(UIImage(named: image), forState: .Normal)
//    titleLabel?.font = UIFont.systemFontOfSize(size)
//}
- (instancetype)initWithTitle:(NSString *)title Color:(UIColor *)color BgIcon:(NSString *)bgIcon Image:(NSString *)image{
    
    if (self = [super init]) {
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:color forState:UIControlStateNormal];
        if (bgIcon != nil) {
            [self setBackgroundImage:[UIImage imageNamed:bgIcon] forState:UIControlStateNormal];
            
            [self setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",bgIcon]] forState:UIControlStateSelected];
        }
        
        [self setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
        
    }
    return self;
}

@end
